package com.zy.explore.web.constraints;


import com.zy.explore.web.constraints.validator.InNumberValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @author Administrator
 */
@Documented
@Constraint(validatedBy = {InNumberValidator.class})
@Target({FIELD, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
public @interface InNumber {

    /**
     * 限制该值范围在此数组中
     *
     * @return long
     */
    long[] value() default {};

    /**
     * 是否必须
     * 是 当该值为 null 时，会进行校验
     * 否 当该值为 null 时，不进行校验
     *
     * @return boolean
     */
    boolean required() default true;

    String message() default "属性值需要在 {value} 范围内";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
